package com.ruoyi.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasicMessageChannel;
import com.ruoyi.system.service.IBasicMessageChannelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息通道Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/basicMessageChannel")
public class BasicMessageChannelController extends BaseController
{
    @Autowired
    private IBasicMessageChannelService basicMessageChannelService;

    /**
     * 查询消息通道列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicMessageChannel basicMessageChannel)
    {
        startPage();
        List<BasicMessageChannel> list = basicMessageChannelService.selectBasicMessageChannelList(basicMessageChannel);
        return getDataTable(list);
    }

    /**
     * 导出消息通道列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:export')")
    @Log(title = "消息通道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicMessageChannel basicMessageChannel)
    {
        List<BasicMessageChannel> list = basicMessageChannelService.selectBasicMessageChannelList(basicMessageChannel);
        ExcelUtil<BasicMessageChannel> util = new ExcelUtil<BasicMessageChannel>(BasicMessageChannel.class);
        util.exportExcel(response, list, "消息通道数据");
    }

    /**
     * 获取消息通道详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:query')")
    @GetMapping(value = "/{messageChannelId}")
    public AjaxResult getInfo(@PathVariable("messageChannelId") Long messageChannelId)
    {
        return success(basicMessageChannelService.selectBasicMessageChannelByMessageChannelId(messageChannelId));
    }

    /**
     * 新增消息通道
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:add')")
    @Log(title = "消息通道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicMessageChannel basicMessageChannel)
    {
        return toAjax(basicMessageChannelService.insertBasicMessageChannel(basicMessageChannel));
    }

    /**
     * 修改消息通道
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:edit')")
    @Log(title = "消息通道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicMessageChannel basicMessageChannel)
    {
        return toAjax(basicMessageChannelService.updateBasicMessageChannel(basicMessageChannel));
    }

    /**
     * 删除消息通道
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessageChannel:remove')")
    @Log(title = "消息通道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{messageChannelIds}")
    public AjaxResult remove(@PathVariable Long[] messageChannelIds)
    {
        return toAjax(basicMessageChannelService.deleteBasicMessageChannelByMessageChannelIds(messageChannelIds));
    }
}
